/*
 * @Description: 生成count的reducer
 * @Author: 姚泽毅
 * @Date: 2021-08-31 17:52:24
 * @LastEditTime: 2021-08-31 17:52:24
 */
import { INCREMENT, DECREMENT } from './constant';

const initState = 0;

export default function countReducer(preState = initState, action) {
    console.log(preState, action);
    const { type, data } = action
    switch (type) {
        case INCREMENT:
            return preState + data
        case DECREMENT:
            return preState - data
        default:
            return preState
    }

}